import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { DelDataButton } from '../Common/options'
import { TunnelInfos } from '../Common/Conversion'

export const TunnelPersonPosition = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        type: '隧道管理',
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'uploadTime@desc' },
        get: API_LIST()[`get${url}`],
        modify: `put${url}`,
        delete: `del${url}`,
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'tunnelInfoUuid',
                title: '隧道',
                valueType: 'select',
                valueEnum: await TunnelInfos(),
                rules: true,
                width: 150,
                hideInSearch: false,
            },
            {
                dataIndex: 'lorR',
                key: 'TunnelLorR',
                title: '部位',
                valueType: 'select',
                valueEnum: BuiltInData.lorR,
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'organizationUuid',
                title: '组织机构',
                valueType: 'select',
                valueEnum: ClientData.organization,
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'tableName',
                key: 'PersonName',
                title: '人员姓名',
                valueType: 'input',
                rules: true,
                width: 100,
                hideInSearch: false,
            },
            {
                dataIndex: 'distance',
                title: '人员位置',
                valueType: 'input',
                rules: true,
                width: 100,
                hideInSearch: true,
            },
            {
                dataIndex: 'position',
                title: '人员位置描述',
                valueType: 'input',
                rules: true,
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'uploadTime',
                title: '上传时间',
                valueType: 'input',
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            { ...commonTableList.code, rules: true, hideInSearch: false, width: 80, title: '隧道编号' },
            // {
            //     dataIndex: 'tagNum',
            //     title: '备注',
            //     valueType: 'input',
            //     rules: true,
            //     width: 200,
            //     hideInSearch: true,
            // },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.StartTime,
            commonTableList.EndTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 100,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '02d34263-9377-4594-a300-010f03b87a0c') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
